import 'package:dio/dio.dart';

class HttpsClient {
  static String baseUrl = 'https://ware.zsdmg.com/web/';
  static Dio dio = Dio();

  HttpsClient() {
    dio.options.baseUrl = baseUrl;
    dio.options.connectTimeout = const Duration(milliseconds: 5000); //5s
    dio.options.receiveTimeout = const Duration(milliseconds: 5000);
  }

  // 封装get请求
  Future get(String url, { Map<String, dynamic>? params }) async {
    try {
      var response = await dio.get(url, queryParameters: params );
      return response;
    } catch (e) {
      return null;
    }
  }
  Future post(String url, [Map<String, dynamic>? params]) async {
    try {
      var response = await dio.post(url, data: params );
      return response;
    } catch (e) {
      print(e);
      return null;
    }
  }


  static imgUrl(pic) {
    String picUrl = baseUrl + pic;
    return picUrl.replaceAll('\\', '/');
  }
  
  
}
